package com.huifaapp.mall.bean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;

/**
 * Created by Administrator on 2018/1/12.
 */

public class CouponListBean {
    public static class Attr {
        public static final String AMOUNT = "amount";
        public static final String NAME = "name";
        public static final String STARTTIME = "startTime";
        public static final String ID = "id";
        public static final String ENDTIME="endTime";
        public static final String USECOND="useCond";
        public static final String TYPE="type";


    }
    /**
     * amount : 110.0
     * name : 从成都出差
     * startTime : 2017-12-13
     * id : 10003
     * endTime : 2018-03-09
     * useCond : 300.0
     * type : red
     */

    private double amount;
    private String name;
    private String startTime;
    private String id;
    private String endTime;
    private double useCond;
    private String type;



    public CouponListBean() {

    }

    public CouponListBean(double amount,String name,String startTime,String id,String endTime,double useCond,String type) {
        super();
        this.amount = amount;
        this.name=name;
        this.startTime=startTime;
        this.id=id;
        this.endTime=endTime;
        this.useCond=useCond;
        this.type=type;

    }
    public static ArrayList<CouponListBean> newInstanceList(String jsonDatas) {
        ArrayList<CouponListBean> AdvertDatas = new ArrayList<CouponListBean>();

        try {
            JSONArray arr = new JSONArray(jsonDatas);
            int size = null == arr ? 0 : arr.length();
            for (int i = 0; i < size; i++) {
                JSONObject obj = arr.getJSONObject(i);
                double amount = obj.optDouble(Attr.AMOUNT);
                String name=obj.optString(Attr.NAME);
                String startTime=obj.optString(Attr.STARTTIME);
                String id=obj.optString(Attr.ID);
                String endTime=obj.optString(Attr.ENDTIME);
                double useCond=obj.optDouble(Attr.USECOND);
                String type=obj.optString(Attr.TYPE);
                AdvertDatas.add(new CouponListBean(amount,name,startTime,id,endTime,useCond,type));
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return AdvertDatas;
    }
    public double getAmount() {
        return amount;
    }

    public void setAmount(double amount) {
        this.amount = amount;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public double getUseCond() {
        return useCond;
    }

    public void setUseCond(double useCond) {
        this.useCond = useCond;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }





}
